﻿var webMethod;
var webServicePath;

// This function shows how to use the 
// WebServiceProxy.invoke method without passing
// parameters.
function GetTime(Param) {
    Sys.Net.WebServiceProxy.invoke(webServicePath,
        webMethod, true, { "Coches": Param }, OnSucceeded,
        OnFailed, "User Context", 1000);

}
function GetRecorridos() {
    Sys.Net.WebServiceProxy.invoke(webServicePath,
        webMethod, true,
        {},
        OnSucceededRecorrido, OnFailed, "User Context", 1000);

}
function OnSucceededRecorrido(result, eventArgs) {
    var RsltElem =
        document.getElementById("HRecorrido");
    RsltElem.value = result;
    // alert (result.toString);

}

function GetRecorrido(Param) {
    Sys.Net.WebServiceProxy.invoke(webServicePath,
        webMethod, true,
        { "IdRecorrido": Param },
        OnSucceededRecorrido, OnFailed, "User Context", 1000);

}

// This function shows how to use the 
// invoke method passing
// parameters and using the GET verb.
// The dictionary field names must match the 
// related Web service method parameter names.
function GetGreetings() {
    Sys.Net.WebServiceProxy.invoke(webServicePath,
        webMethod, true,
        { "greeting": "Have a nice day", "name": " to You (via GET)!" },
        OnSucceeded, OnFailed, "User Context", 100);

}


// This function shows how to use the 
// invoke method passing parameters and using the POST verb.
// The dictionary field names must match the 
// related Web service method parameter names.
function PostGreetings() {
    Sys.Net.WebServiceProxy.invoke(webServicePath,
        webMethod, false,
        { "greeting": "Have a nice day", "name": " to You (via POST)!" },
        OnSucceeded, OnFailed, "User Context", 100);

}


function OnSucceeded(result, eventArgs) {
    var RsltElem =
        document.getElementById("Hidden1");
    RsltElem.value = result;


    // alert (result.toString);

}


// This is the callback function invoked 
// if the Web service failed.
function OnFailed(error) {
    //alert("Service Error: " + error.get_message());
}



function EjecuarWebServices(strwebServicePath, strwebMethod, Param) {
    webMethod = strwebMethod;
    webServicePath = strwebServicePath;

    switch (webMethod) {
        case "GetSelectObjectXML":
            GetTime(Param);
            break;
        case "GetXmlRecorridos":
            GetRecorridos();
            break;
        case "GetXmlRecorrido":
            GetRecorrido(Param);
            break;

        default:

    }
}

if (typeof (Sys) !== "undefined") Sys.Application.notifyScriptLoaded();


